/**
 * Author:   anTi
 * Date:     2018/11/24 12:47
 * Description:
 * version: 1.0
 */

package com.imooc.avtiviti.event;

import org.activiti.engine.delegate.event.ActivitiEvent;
import org.activiti.engine.delegate.event.ActivitiEventListener;
import org.activiti.engine.delegate.event.ActivitiEventType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

//自定义监听器
public class JobCustomEventListener implements ActivitiEventListener {
    private static final  Logger LOGGER= LoggerFactory.getLogger(JobCustomEventListener.class);
    @Override
    public void onEvent(ActivitiEvent activitiEvent) {
        //流程开始打印日志
        //流程结束打印日志
        ActivitiEventType type = activitiEvent.getType();
        String name = type.name();
        if (name.startsWith("TIMER")||name.startsWith("JOB")){
            LOGGER.info("监听到Job事件启动 {} \t {}",type,activitiEvent.getProcessInstanceId());
        }
    }

    @Override
    public boolean isFailOnException() {
        return false;
    }

}
